#===================
# Author: Huang Gang
# Date: 2017-09-19
#===================
import web
import mimetypes
import config

render = web.template.render('templates')

class public:
    def GET(self):
        public_dir = 'public'
        try:
            file_name = web.ctx.path.split('/')[-1]
            web.header('Content-type', mime_type(file_name))
            return open(public_dir + web.ctx.path, 'rb').read()
        except IOError:
            raise web.notfound()

def mime_type(filename):
    return mimetypes.guess_type(filename)[0] or 'application/octet-stream'

class help:
    def GET(self):
        return render.help()

class tactics_detail:
    def GET(self):
        strategy_info = config.sjk.strategy_coll.find({},{"strategy_name": 1, 'total_gain':1,'username':1,'strategy_type':1,'subscribe_count':1,'price':1})
        return render.tactics_detail(strategy_info)
